//
// Copyright (c) 2009-2011, chunquedong
//
// This file is part of ChunMap project
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
//
// History:
//   2011-05-05  Jed Young  Creation
//

using fwt
using gfx

**
** ZoomTool
**
@Js
class ZoomTool : Tool
{
  override Void actionEvent(Event e)
  {
    if (e.id != EventId.mouseWheel) return
    mouseWheelMoved(e)
  }

  private Void mouseWheelMoved(Event e)
  {
    x := map.view.x2World(e.pos.x.toFloat)
    y := map.view.y2World(e.pos.y.toFloat)

    if (e.delta == null || e.delta.y == 0) return
    s := (e.delta.y < 0) ? 2f : 0.5f

    cmd := ZoomCommand(map, s, x, y)
    map.executeCommand(cmd)

    e.consume
    map.renderMap
  }
}

